package com.tul.exercise.base.operator.egs;


import org.junit.jupiter.api.Test;

import java.util.Random;
import static com.tul.exercise.base.utils.Print.print;

/**
 * @Description 《java编程思想》第3章 示例3：
 *
 *  java中的操作符
 *
 **/
public class eg_02_MathOps {

    @Test
    public void test() {
        Random rand = new Random(47);

        int i,j,k;

        j = rand.nextInt(100) + 1;
        print("j : " + j);

        k = rand.nextInt(100) + 1;
        print("k : " + k);

        i = j + k;
        print("j + k : " + i);

        i = j - k;
        print("j - k : " + i);

        i = j / k;
        print("j / k : " + i);

        i = j * k;
        print("j * k : " + i);

        i = j % k;
        print("j % k : " + i);

        j  %= k;
        print("j  %= k : " + j);

        float u,v,w;
        u = rand.nextFloat();
        print("u : " + u);

        v = rand.nextFloat();
        print("v : " + v);

        w = v + u;
        print("v + u : " + w);

        w = v - u;
        print("v - u : " + w);

        w = v * u;
        print("v * u : " + w);

        w = v / u;
        print("v / u : " + w);

        u += v;
        print("u += v : " + u);

        u -= v;
        print("u -= v : " + u);

        u *= v;
        print("u *= v : " + u);

        u /= v;
        print("u /= v : " + u);
    }
}
